home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
476-500
/
disk_488
/
lordofhosts
/
lohsrc.lzh
/
misc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-10
|
12KB
|
378 lines
/* LORD OF HOSTS - misc.c --- Verschiedene Dienstleistungsroutinen */
#include "Lord.h"
extern ULONG JoyMouseData;
char players[2][16];
extern int status;
extern BOOL joymouse_on, joymouse_allowed;
struct TRStructure MyTextStruct;
void Rules(void)
{
short result=0;
int nr=-1;
MyTextStruct.KeyMask=0xFFFF;
MyTextStruct.textcolor=1;
MyTextStruct.detailcolor = 0;
MyTextStruct.blockcolor = 1;
MyTextStruct.versionnumber = 0;
MyTextStruct.rfu1 = 0;
MyTextStruct.rfu2 = 0;
while (result!=1)
{
if (result==0) ++nr;
if (result==2) --nr;
switch (nr)
{
case 0:
MyTextStruct.Title="Rules: Page 1";
MyTextStruct.PositiveText = "Resume";
MyTextStruct.NegativeText = "Next Page";
MyTextStruct.MiddleText = NULL;
MyTextStruct.Text =
" LORD OF HOSTS\n"
" =============\n\n"
"Each player controls seven Knights\n"
"and one King (that's the one with the\n"
"crown). The aim of the game is to\n"
"defeat the opponent by:\n"
" - capturing his King or\n"
" - beating all but one of his Knights\n\n"
"Players should aim to attack their\n"
"opponent's pieces while defending\n"
"their own.\n\n\n\n\n\n";
break;
case 1:
MyTextStruct.Title="Rules: Page 2";
MyTextStruct.PositiveText = "Resume";
MyTextStruct.NegativeText = "Next Page";
MyTextStruct.MiddleText = "Prev Page";
MyTextStruct.Text =
" How To Play\n\n"
"Select 'Begin Game' (Game Menu) and\n"
"enter your and your opponent's names.\n"
"The computer decides who will start\n"
"the game.\n"
"Player 1 uses the mouse to control the\n"
"pointer; Player 2 can use a joystick.\n"
"After one player has finished his\n"
"move, control over the pointer will be\n"
"given to his opponent.\n"
"On the right side of the screen there\n"
"are two boxes containing the names of\n"
"the players. They also indicate whose\n"
"turn it is by changing the color of\n"
"the words 'Player 1/2' to blue.\n"
"The color changes to yellow when the\n"
"computer is waiting for a move to be\n"
"confirmed (see page 9).";
break;
case 2:
MyTextStruct.Title="Rules: Page 3";
MyTextStruct.Text =
" How To Move\n\n"
"Click once (left mouse button or\n"
"joystick fire button) over the piece\n"
"you want to move. The number\n"
"indicated on the piece is the number\n"
"of squares this piece HAS GOT TO move.\n"
"The pieces can only be moved\n"
"horizontally or vertically (NOT\n"
"diagonally); however, you are allowed\n"
"one right-angle-turn per move. That\n"
"is, a value of 4 might be used to move\n"
"the piece 1 square up and 3 to the\n"
"left.\n"
"A piece can't jump over any other\n"
"piece. Also, a piece can't move\n"
"forwards and backwards in one move.\n\n";
break;
case 3:
MyTextStruct.Title="Rules: Page 4";
MyTextStruct.Text =
" How To Move (cont'd)\n\n"
"Click once on the square you want the\n"
"selected piece to move to. If the\n"
"move is valid, the piece will move\n"
"there. If it isn't, you can select\n"
"another square or another piece to\n"
"move with. You can obtain an\n"
"explanation for why the computer\n"
"refused to move your piece by\n"
"selecting 'Explain Invalid Move'\n"
"(Special Menu).\n"
"A move is invalid if\n"
" - you try to move too far\n"
" - you don't move far enough\n"
" - the way is blocked\n"
" - an opponent's piece can beat your\n"
" King (just like in chess).\n";
break;
case 4:
MyTextStruct.Title="Rules: Page 5";
MyTextStruct.Text =
" How to Capture\n\n"
"Any piece can capture any of the\n"
"opponent's pieces by landing on the\n"
"square occupied by the piece at the\n"
"end of a move. The King is the only\n"
"piece that cannot be captured in this\n"
"way. If a King is standing on a square\n"
"where he could be captured, 'Check'\n"
"is announced. In the following move,\n"
"the attacked player must either\n"
" - move his King out of danger or\n"
" - block the way between the King and\n"
" the threatening piece with another\n"
" piece or\n"
" - capture the threatening piece.\n"
"If he is unable to do any of these,\n"
"the game is over.\n";
break;
case 5:
MyTextStruct.Title="Rules: Page 6";
MyTextStruct.Text =
" The End Of The Game\n\n"
"As indicated on the previous page, the\n"
"game is over when one of the players\n"
"can't do any valid moves anymore.\n"
"Another way of ending the game is to\n"
"capture all of the opponent's Knights\n"
"except for one. A player who finds\n"
"himself with only his King and one\n"
"Knight has lost the battle.\n\n\n\n\n\n\n\n\n";
break;
case 6:
MyTextStruct.Title="Rules: Page 7";
MyTextStruct.Text =
" Explanation Of The Menus (1)\n\n"
"GAME Menu:\n"
"Begin Game : Begin a new game.\n"
"Load Game : Load a game.\n"
"Save Game : Save current game. The\n"
" whole game will be saved (not only\n"
" the current positions).\n"
"Rules : Guess what.\n"
"About : Some infos about LORD.\n"
"Quit : Well, quit.\n\n\n\n\n\n\n\n";
break;
case 7:
MyTextStruct.Title="Rules: Page 8";
MyTextStruct.Text =
" Explanation Of The Menus (2)\n\n"
"BOARD Menu:\n"
"Standard : Lord Of Hosts is based on\n"
" a board game. The pieces' values are\n"
" determined by little magnets inside\n"
" the board. This is the simulation of\n"
" the original board.\n"
"Rotated 90°: Same board, rotated by\n"
" 90° (results in different number\n"
" patterns).\n"
"Balanced Rnd: Computer generated ran-\n"
" dom board. However, the 64 possible\n"
" values (8*8) are distributed evenly\n"
" to each piece (16*1,16*2,etc.)\n"
"Unbalanced : No even distribution of \n"
" piece values.\n\n";
break;
case 8:
MyTextStruct.Title="Rules: Page 9";
MyTextStruct.PositiveText = "Resume";
MyTextStruct.NegativeText = "Next Page";
MyTextStruct.MiddleText = "Prev Page";
MyTextStruct.Text =
" Explanation Of The Menus (3)\n"
"SPECIAL Menu:\n"
"Undo : Undoes last move. Can be used\n"
" to undo the last 500 moves one after\n"
" another. Most games are much shorter.\n"
" Works also with loaded games!\n"
"Redo : Redoes one move that has been\n"
" previously undone. Can only work if\n"
" no new moves have occurred since the\n"
" last 'Undo'.\n"
"Help Mode : The computer can help you\n"
" in deciding which move to do. By\n"
" selecting 'Show Known Values' you are\n"
" given a chance to look at the new\n"
" value the piece will have after the\n"
" move IF THE PIECE HAS BEEN THERE\n"
" BEFORE. 'Show All Values' will always\n"
" show the new value. You can confirm\n"
" the move (click dest.) or try again.";
break;
case 9:
MyTextStruct.Title="Rules: Page 10";
MyTextStruct.PositiveText = "Resume";
MyTextStruct.NegativeText = NULL;
MyTextStruct.MiddleText = "Prev Page";
MyTextStruct.Text =
" Explanation Of The Menus (3)\n\n"
"SPECIAL Menu (cont'd):\n"
"JoyMouse : If you don't wish that\n"
" player 2 should use a joystick to\n"
" move the mouse pointer, you can turn\n"
" off this feature by selecting 'off'. \n"
"Set JoyMouse Speed : If you don't\n"
" like the mouse pointer's speed when\n"
" steered by Joystick, you can change\n"
" it with this menu item. Useful with\n"
" mouse accelerators.\n"
"Switch Sides : Currently unimplemented\n"
" feature for the version of LORD in\n"
" which you will be playing against the\n"
" COMPUTER...\n"
"Explain Invalid Move : Brings up a\n"
" requester telling you why the last\n"
" move had to be rejected.";
break;
default:
MyTextStruct.Text = NULL;
break;
}
result = TextRequest(&MyTextStruct);
}
}
void About(void)
{
SimpleRequest(
" LORD OF HOSTS V1.0\n"
" ==================\n\n"
" Programmed by:\n"
" Tim Pietzcker\n"
" Schwarzwaldstr.52\n"
" W-7819 Denzlingen, Germany\n"
"Copyright © 1991. All Rights Reserved.\n\n"
"Many thanks to the developers of the\n"
"CygnusEd Pro (Release 2) for both this\n"
"great editor and the req.library!\n"
" Written in ANSI C (Aztec C V5.0d)\n\n"
"This program may be freely distributed\n"
"as long as this notice remains intact.\n"
"Distribution in PD series other than\n"
"Fred Fish's requires written permis-\n"
"sion from the author (that's me!).");
}
void ExplainError(int Error)
{
char errtext[300]="The last move I rejected was invalid\nbecause";
if (!Error) strcpy(errtext,"There has been no invalid move");
if (Error & DIST_EXCEEDED)
strcat(errtext,"\n - you'd have moved the piece too far");
if (Error & MUST_MOVE_FARTHER)
strcat(errtext,"\n - you didn't move far enough");
if (Error & WAY_BLOCKED)
strcat(errtext,"\n - the way was blocked");
if (Error & KING_IN_DANGER)
strcat(errtext,"\n - your King must not be left\n exposed to danger");
strcat(errtext,"!");
SimpleRequest(errtext);
}
void SetJMSpeed(void)
{
struct GetLongStruct MyGetLongStruct;
MyGetLongStruct.titlebar = "New JoyMouse Speed:";
MyGetLongStruct.defaultval = (LONG)JoyMouseData;
MyGetLongStruct.minlimit = 1;
MyGetLongStruct.maxlimit = 10;
MyGetLongStruct.window = 0;
MyGetLongStruct.versionnumber = 0;
MyGetLongStruct.flags = 0;
MyGetLongStruct.rfu2 = 0;
if (GetLong(&MyGetLongStruct))
{
Forbid();
JoyMouseData=(ULONG)MyGetLongStruct.result;
Permit();
}
}
void EnterNames(void)
{
do
GetString(players[0], "Player 1, please enter your name:", NULL, 38, 16);
while (strchr((const char *)players[0],'%'));
do
GetString(players[1], "Player 2, please enter your name:", NULL, 38, 16);
while (strchr((const char *)players[1],'%'));
drawplayers(players[0],players[1]);
}
BOOL Coords(SHORT MouseX, SHORT MouseY, UBYTE *x, UBYTE *y)
{
MouseX-=2; MouseY-=13;
if (MouseX<0 || MouseY<0 || MouseX>183 || MouseY>183) return FALSE;
*x = MouseX / 23;
*y = MouseY / 23;
return TRUE;
}
void Exchange(UBYTE *a, UBYTE *b)
{
UBYTE c;
c = *a;
*a = *b;
*b = c;
}
void Notify(int Nr, int occurrence)
{
char notice[200];
if (occurrence == ENEMY_KNIGHT_BEATEN) return;
occurrence &= (~ENEMY_KNIGHT_BEATEN);
if (occurrence)
{
strcpy(notice,players[Nr]);
if (occurrence & ENEMY_KING_BEATABLE)
{
strcat(notice," announces 'CHECK!'\n");
if (occurrence > ENEMY_KING_BEATABLE)
strcat(notice,"and");
}
if (occurrence > ENEMY_KING_BEATABLE)
{
strcat(notice," wins the game!\n");
if (occurrence & ENEMY_MATED)
{
strcat(notice,players[1-Nr]);
strcat(notice,"'s King is checkmated !\n");
}
if (occurrence & ENEMY_OUT_OF_KNIGHTS)
{
strcat(notice,players[1-Nr]);
strcat(notice," has lost six Knights!\n");
}
status &=(~(WAITING_FOR_PICK|WAITING_FOR_DEST|WAITING_FOR_CONF|IN_GAME));
NextPlayer(RED); /* schaltet JoyMouse aus und setzt Farben zurück */
}
SimpleRequest(notice);
}
}
void NextPlayer(BOOL who)
{
if (who == RED)
{
if (joymouse_on) swapjoymouse(FALSE);
if (status & IN_GAME)
DrawText(9,JAM1,223,16,"Player 1");
else
DrawText(1,JAM1,223,16,"Player 1");
DrawText(1,JAM1,223,49,"Player 2");
} else { /* who == WHITE */
if (joymouse_allowed && !joymouse_on) swapjoymouse(TRUE);
DrawText(1,JAM1,223,16,"Player 1");
if (status & IN_GAME)
DrawText(9,JAM1,223,49,"Player 2");
else
DrawText(1,JAM1,223,49,"Player 2");
}
}